package com.huarui.purchaseOrder.dao.impl;

import java.util.List;
import java.util.Map;

import org.ewaf.framework.dao.impl.BaseDaoImpl;
import com.huarui.purchaseOrder.dao.IPurchaseOrderDao;
import com.huarui.purchaseOrder.model.PurOrSaleOrder;

public class PurchaseOrderDaoImpl extends BaseDaoImpl implements IPurchaseOrderDao{

	@Override
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getOrdersByCondition(Map map) {
		return getSqlMapClientTemplate().queryForList(namespace+".getOrdersByCondition", map);
	}

	@Override
	@SuppressWarnings("unchecked")
	public Integer getOrdersCountByCondition(Map map) {
		return (Integer) getSqlMapClientTemplate().queryForObject(namespace + ".getOrdersCountByCondition", map);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Map getOrderByIdJson(Integer id) {
		
		return (Map) getSqlMapClientTemplate().queryForObject(namespace + ".getOrderById", id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean updatePurCurrentorIdById(Map map) {
		return getSqlMapClientTemplate().update(namespace + ".updateCurrentorById", map) == 1;
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public Map<String, Object> getPurchaseById(Map<String, Object> map) {
		return (Map<String, Object>) getSqlMapClientTemplate().queryForObject(namespace + ".getPurchaseById", map);
	}

//	@Override
//	public Integer getPurchaseNumByComplex(Map<String, Object> paramsMap) {
//		return (Integer) this.getSqlMapClientTemplate().queryForObject(namespace + ".getPurComplexCountInfo", paramsMap);
//	}
	
//	@Override
//	@SuppressWarnings("unchecked")
//	public List<Map<String, Object>> getPurChaseListByComplex(Map<String, Object> map) {
//		return (List<Map<String, Object>>) getSqlMapClientTemplate().queryForList(super.namespace + ".getPurChaseListByComplex", map);
//	}

//	@Override
//	public Integer getPursNumByBuyer(Integer buyerId) {
//		return (Integer) this.getSqlMapClientTemplate().queryForObject(super.namespace + ".getPursNumByBuyer", buyerId);
//	}
	
	@Override
	public Integer getPurchaseOrderListCountByComplex(Map<String, Object> map) {
		return (Integer) this.getSqlMapClientTemplate().queryForObject(super.namespace + ".getPurCountByComplex", map);
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getPurchaseOrderListByComplex(Map<String, Object> map) {
		return (List<Map<String, Object>>) this.getSqlMapClientTemplate().queryForList(super.namespace + ".getPurInfoByComplex", map);
	}
	
	@Override
	public boolean updatePurCurrenterId(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".updateCurrenterId", paramsMap);
	}

	@Override
	public boolean takeOverSaleOrder(Map<String, Object> paramsMap) {
		return this.getSqlMapClientTemplate().update(super.namespace + ".takeOverSaleOrder", paramsMap) == 1;
	}

	@Override
	public boolean turnBackSaleOrder(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".turnBackSaleOrder", paramsMap);
	}

	@Override
	public boolean updateStatus(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".updateStatus", paramsMap);
	}
	
	@Override
	public boolean deleteById(Object id) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".deleteById", id);
	}

	@Override
	public boolean updateOrdersStatusAndReceiveOrSaleId(Map<String, Object> map) {
		return getSqlMapClientTemplate().update(namespace+".updateOrdersStatusAndReceiveOrSaleId",map) == 1;
	}
}
